package com.mojito.learn.module.other.work;

import com.mojito.common.util.FirstCharUtils;

import java.util.Arrays;

/**
 * @author liufq
 * @date 2022/1/5 下午2:13
 */
public class DictGenerate {

    public static void main(String[] args) {
        String dictCode = "d_medical_type_wz";
        String codeName = "温州医疗类别";
        String dml = "11\t普通门诊\t41\t定点药店购药\n" +
                "12\t门诊挂号\t51\t生育门诊\n" +
                "13\t急诊\t52\t生育住院\n" +
                "14\t门诊慢特病\t53\t计划生育手术费\n" +
                "21\t普通住院\t91\t其他门诊\n" +
                "22\t外伤住院\t92\t其他住院\n" +
                "23\t转外诊治住院\t93\t其他购药\n" +
                "24\t急诊转住院\t99\t地方扩展医疗类别\n" +
                "15\t特药\t9113\t慢特外检外购经办批准\n" +
                "16\t中医特色门诊\t9114\t慢特异地长期居住\n" +
                "18\t特药购药\t9201\t转外地住院备案\n" +
                "25\t异地住院\t9202\t转外地住院未备案\n" +
                "26\t单病种住院\t9203\t意外伤害住院备案\n" +
                "27\t自主就医\t9204\t意外伤害转外住院备案\n" +
                "28\t日间手术\t9205\t意外伤害转外住院未备案\n" +
                "29\t起付线治疗\t9206\t意外伤害住院未备案\n" +
                "30\t探亲旅游住院\t9207\t肝移植报销\n" +
                "31\t院前抢救\t9208\t长期护理专护\n" +
                "56\t基本医疗计划生育手术\t9209\t长期护理养护\n" +
                "61\t照护保险\t9211\t随同住院报销\n" +
                "71\t家庭病床\t9301\t大额自费购药\n" +
                "81\t意外伤害门诊\t990101\t门诊单病种\n" +
                "110101\t个人账户下账\t990102\t转诊门诊\n" +
                "110103\t门诊急诊抢救期间死亡\t990103\t新冠病毒核酸检测\n" +
                "110104\t门诊统筹\t990201\t大额普通门诊\n" +
                "110202\t特药门诊\t990301\t统筹区内转院\n" +
                "1103\t癌症筛查\t990302\t医疗专护\n" +
                "1104\t异地门诊慢特病\t990401\t普通住院（新生儿随父母报销）\n" +
                "1301\t急诊抢救\t990402\t残疾人辅助器具门诊\n" +
                "140101\t门诊大病\t990403\t机构护理\n" +
                "140104\t门诊慢病\t990404\t门诊特检特治(阴性)\n" +
                "140201\t门诊特病\t990502\t特殊情况门诊\n" +
                "140401\t门诊罕见病\t990503\t日间病床\n" +
                "210101\t重大疾病住院\t990601\t无他方责任意外伤害住院\n" +
                "210103\t院外费用\t990602\t血液特殊病\n" +
                "210104\t急诊住院\t9907\t门诊特检特治(阳性)\n" +
                "210201\t急诊(死亡)\t990801\t安宁疗护住院\n" +
                "210302\t罕见病住院\t990802\t特殊项目报销\n" +
                "210303\t精神病住院\t990901\t特殊病住院\n" +
                "210304\t分级诊疗住院\t990902\t门诊专项用药\n" +
                "2109\t新生儿抢救\t990903\t转外慢性病\n" +
                "2199\t大病关怀\t9910\t异地安置人员急诊住院\n" +
                "240101\t视同本地急诊住院\t991102\t特殊用药\n" +
                "240102\t住院前急诊\t991201\t重流疾病\n" +
                "2402\t转外住院前急诊\t991202\t分疗程间断住院治疗\n" +
                "3101\t低自付住院\t991301\t市外继续治疗\n" +
                "3102\t低自付门诊\t991302\t非定点生育报销\n" +
                "510101\t配偶门诊产前检查\t991401\t门诊抢救\n" +
                "510102\t产前检查\t991402\t非定点生育住院报销\n" +
                "5201\t配偶生育住院（职工）\t991501\t门诊抢救死亡（市外）\n" +
                "520101\t保胎住院\t991502\t非定点计划生育手术费\n" +
                "520102\t生育定额住院\t991601\t医疗照顾对象门诊\n" +
                "5202\t非生产住院\t991602\t公务员困难救助\n" +
                "5203\t配偶非生产住院\t991701\t重流门诊\n" +
                "5204\t配偶生育转外住院\t991702\t18周岁以下苯丙酮尿症\n" +
                "5205\t转外非生产住院\t991802\t18周岁以下四氢生物蝶呤缺乏症\n" +
                "5206\t配偶转外非生产住院\t991901\t妊娠合并症（并发症）\n" +
                "5207\t其他生育相关住院\t991902\t18周岁以下苯丙酮尿症及四氢生物蝶呤缺乏症\n" +
                "5208\t生育保胎\t992001\t门检特检特治\n" +
                "530102\t计划生育门诊\t992002\t大学生外伤门诊\n" +
                "530202\t计划生育住院\t992101\t终止妊娠\n" +
                "5304\t配偶计划生育门诊治疗\t992102\t透析\n" +
                "5305\t生育转外住院\t992103\t异地安置住院\n" +
                "9101\t外检\t9922\t自主就医住院\n" +
                "910201\t外治\t9929\t药店购慢特病药\n" +
                "910202\t国家谈判药门诊\t9933\t透析治疗\n" +
                "9103\t外购\t9934\t床日费用住院\n" +
                "9105\t门诊手术转外\t9935\t独立门诊部个人帐户支付\n" +
                "910601\t门诊手术转外未备案\t9936\t外伤转院\n" +
                "910602\t全口义齿\t9937\t外伤急诊住院\n" +
                "9107\t体检\t9111\tPET检查\n" +
                "9108\t外伤门诊\t9112\t慢特外检外购定点批准\n" +
                "9110\t住院前门诊\t\t";

        StringBuilder builder = new StringBuilder("# " + codeName + "字典\n");
        builder.append("INSERT INTO cloud_his_common.dict_code (code, name, name_py_abbr, notes, sort_code, is_shared, is_can_add, is_closed, is_deleted, user_created, user_modified, gmt_created, gmt_modified) VALUES ('");
        builder.append(dictCode);
        builder.append("', '");
        builder.append(codeName);
        builder.append("', '");
        builder.append(FirstCharUtils.getFirst(codeName));
        builder.append("', null, 0, 0, 0, 0, 0, 0, 0, NOW(), NOW());");
        builder.append("\n\n");

        Arrays.asList(dml.split("\n")).forEach(o -> {
            String name = o.split("\t")[1];
            String value = o.split("\t")[0];

            builder.append("INSERT INTO cloud_his_common.dict_item (code, name, name_py_abbr, value, notes, sort_code, is_closed, is_deleted, user_created, user_modified, gmt_created, gmt_modified) VALUES ('");
            builder.append(dictCode);
            builder.append("', '");
            builder.append(name);
            builder.append("', '");
            builder.append(FirstCharUtils.getFirst(name));
            builder.append("', '");
            builder.append(value);
            builder.append("', null, 0, 0, 0, 0, 0, NOW(), NOW());\n");
        });
        System.out.println(builder.toString());
    }
}
